import APIService from './APIService';

// 三轴龙门机械臂接口
class GantryService {
  // 原料出库
  static materialOutbound() {
    const path = '/mes/gantry';
    const data = {
      action: "take_from_warehouse",
      warehouse_type: "material",
    };
    return APIService.post(path, data);
  }

  // 原料入库
  static materialInbound() {
    const path = '/mes/gantry';
    const data = {
      action: "put_to_warehouse",
      warehouse_type: "material",
    };
    return APIService.post(path, data);
  }

  // 合格品入库
  static qualifiedInbound() {
    const path = '/mes/gantry';
    const data = {
      action: "put_to_warehouse",
      warehouse_type: "product_ok",
    };
    return APIService.post(path, data);
  }

  // 不合格品入库
  static nonQualifiedInbound() {
    const path = '/mes/gantry';
    const data = {
      action: "put_to_warehouse",
      warehouse_type: "product_ng",
    };
    return APIService.post(path, data);
  }
}

// AGV小车接口类
class AgvCarService {
  // 前往下一个停靠点
  static advanceToNextStop() {
    const path = '/mes/agv-car';
    const data = {
      action: "advance"
    };
    return APIService.post(path, data);
  }

  // 前往停靠点1，若在则不移动
  static returnToHomeStop() {
    const path = '/mes/agv-car';
    const data = {
      action: "back_home"
    };
    return APIService.post(path, data);
  }
}

// 六轴机械臂接口
class SixRobotArm {
  // 六轴机械臂从AGV小车取料
  static fetchFromCar() {
    const path = '/mes/robot-arm/6axis';
    const data = {
      action: "take_from_car"
    };
    return APIService.post(path, data);
  }

  // 六轴机械臂向AGV小车放料
  static placeToCar() {
    const path = '/mes/robot-arm/6axis';
    const data = {
      action: "put_to_car"
    };
    return APIService.post(path, data);
  }
}

// 四轴机械臂接口类
class FourRobotArm{
  // 机械臂上升
  static raiseArm() {
    const path = '/mes/robot-arm/4axis';
    const data = {
      action: "ascend"
    };
    return APIService.post(path, data);
  }

  // 机械臂下降
  static lowerArm() {
    const path = '/mes/robot-arm/4axis';
    const data = {
      action: "descend"
    };
    return APIService.post(path, data);
  }

  // 质检器质检(结合机械臂）
  static qualityCheck() {
    const path = '/mes/robot-arm/4axis';
    const data = {
      action: "auto_move_and_detect"
    };
    return APIService.post(path, data);
  }
}

//质检器接口（单独）
class QualityInspector {
  // 执行质检
  static performDetection() {
    const path = '/mes/robot-arm/quality-inspector';
    const data = {
      action: "detect"
    };
    return APIService.post(path, data);
  }
}

// 打标机接口
class MarkingMachine {
  // 打印二维码
  static printImage() {
    const path = '/mes/mark-machine';
    const data = {
      action: "print_image"
    };
    return APIService.post(path, data);
  }
}


export { GantryService, AgvCarService, SixRobotArm, FourRobotArm, QualityInspector, MarkingMachine};
